﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Site_Extractor;
using Common;
using MIL.Html;
using System.Text.RegularExpressions;
using System.Net;
using Indexing;
using System.Text;

namespace Forums_Extractor
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[MTAThread]
		static void Main()
		{
			/*Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new ForumsExtractorGUI());*/		
			
			//var ls = new List<string>();
			//var links = Crawler.Crawl("http://forums.walla.co.il/?w=/310/3132", ref ls, 0);
			//GenericForum f1=CreateFresh(), f2=CreateNana(), f3=CreateTapuz(), f4=CreateWalla();
			//f1.SaveToXml(".");
			//f2.SaveToXml(".");
			//f3.SaveToXml(".");
			//f4.SaveToXml(".");

			/*ServicePointManager.DefaultConnectionLimit = 100;

			var msgs = new List<ForumMessage>();
			var fs = new List<GenericForum>();
			fs.Add(CreateFresh());
			fs.Add(CreateTapuz()); 
			fs.Add(CreateWalla()); 
			fs.Add(CreateNana());
			//fs.Add(CreateHyde());

			DateTime from = DateTime.Now-new TimeSpan(7,0,0,0);
            Console.WriteLine("Starting Forum Indexing : " + DateTime.Now.ToString());
			foreach (GenericForum f in fs)
			{
				var gethered = f.ExtractForum(15, from);
				msgs.AddRange(gethered);				
			}
            Console.WriteLine("Ended Forum Indexing : " + DateTime.Now.ToString());
			Console.WriteLine("Collected total of {0} messages from {1} forums", msgs.Count, fs.Count);*/
			//TestForum(CreateTapuzClubs());

			/*Site blogSite = new Site("http://www.showme.co.il", "hebrew");
			blogSite.SiteNames = new SiteNames();
			blogSite.SiteNames.SiteName = "showme.co.il";
			Rule[] rules=new Rule[4];
			for (int i = 0; i < rules.Length; i++) rules[i] = new Rule();
			rules[0].Name = Rule.Story;
			rules[0].PropertyName = "td";
			rules[0].AttributeName = "class";
			rules[0].AttributeValue = "w3";

			rules[1].Name = Rule.Title;
			rules[1].PropertyName = "div";
			rules[1].AttributeName = "class";
			rules[1].AttributeValue = "w6b";


			rules[2].Name = Rule.Datetime;
			rules[2].PropertyName = "div";
			rules[2].AttributeName = "dir";
			rules[2].AttributeValue = "rtl";

			rules[3].Name = Rule.Summary;			

			blogSite.RuleSets.Add(new RuleSet("Story", new List<Rule>(rules)));*/
			//string address = "http://www.haaretz.co.il/hasite/spages/1090741.html";
			//Uri Uaddr=new Uri(address);
			//string page = HtmlDownloader.DownloadPage(Uaddr);
			//var n = HtmlStripper.GetTextFromHtml(page, true);
			//var title = HtmlStripper.GetTitleFromHtml(page);
			//var d = HtmlStripper.GetDateTimeFromHtml(n);
			//var s = SiteExtractor.ExtractStory(blogSite, Uaddr, page);

			GenericForum f = CreateFresh();
			f.SaveToXml(".");
			f = CreateHyde();
			f.SaveToXml(".");
			f = CreateNana();
			f.SaveToXml(".");
			f = CreateTapuz();
			f.SaveToXml(".");
			f = CreateTapuzClubs();
			f.SaveToXml(".");
			f = CreateWalla();
			f.SaveToXml(".");
			Console.WriteLine("Press enter to exit");
			Console.ReadLine();
		}
		private static void TestForum(GenericForum f)
		{
			try
			{
				var links = f.GetAllForumLinks();
				var link = links[new Random().Next(links.Count)];
				var msgLinks = f.GetAllMessageLinks(link);
				var msgLink = msgLinks[new Random().Next(msgLinks.Count)];
				var msg = f.GetMessage(msgLink.Link);
			}
			catch { }
		}
		private static GenericForum CreateTapuz()
		{
			GenericForum f = new GenericForum();
			f.Name = "Tapuz Forums";
			f.MainLink = "http://www.tapuz.co.il/forums/forumsListNew.asp";

			string _linkPrefix = "http://www.tapuz.co.il/forums2008/forumpage.aspx?forumid=";

			ForumRule
				fId0 = new ForumRule();

			fId0.ruleAction = RuleAction.RxMatch;
			fId0.actionParams = new object[] { Regex.Escape(_linkPrefix)+@"(.\d+)"};

			f.RuleForumIdentifier = fId0;
			
			ForumRule
				fLink0 = new ForumRule(),
				fLink1 = new ForumRule(),
				fLink2 = new ForumRule(),
				fLink3 = new ForumRule();

			fLink0.ruleAction = RuleAction.AddToString;
			fLink0.actionParams = new object[] { "&r=1" };
			fLink0.nextRule = fLink1;
			fLink1.ruleAction = RuleAction.DownloadPage;
			fLink1.actionParams = new object[] { "utf-8" };
			fLink1.nextRule = fLink2;
			fLink2.ruleAction = RuleAction.RemoveChars;
			fLink2.actionParams = new object[] { '\r','\n','\t'};
			fLink2.nextRule = fLink3;
			fLink3.ruleAction = RuleAction.GetMessageLinksRx;
			fLink3.actionParams = new object[] { @"a\((?<link>.*?(?<date>\d{2}/\d{2}/\d{2} \d{2}:\d{2}).*?)\);", "dd/MM/yy HH:mm" };

			f.RuleMessageLinks = fLink0;

			ForumRule
				mDate0 = new ForumRule(), mDate1 = new ForumRule(),
				mText0 = new ForumRule(), mTopic0 = new ForumRule(),
				mId = new ForumRule();

			mDate0.ruleAction = RuleAction.GetRxMatches;
			mDate0.actionParams = new object[] { @"\d\d/\d\d/\d\d \d\d:\d\d", 0, 0 };
			mDate0.nextRule = mDate1;

			mDate1.ruleAction = RuleAction.GetDate;
			mDate1.actionParams = new object[] { "dd/MM/yy HH:mm" };

			f.RuleMessageDate = mDate0;
			
			mText0.ruleAction = RuleAction.GetRxMatches;
			mText0.actionParams = new object[] { @"'([^']*)'",0,2 };

			f.RuleMessageText = mText0;

			mTopic0.ruleAction = RuleAction.GetRxMatches;
			mTopic0.actionParams = new object[] { @"'([^']*)'", 0, 1 };

			f.RuleMessageTopic = mTopic0;

			mId.ruleAction = RuleAction.GetRxMatches;
			mId.actionParams = new object[] { @"(\d+)" , 0, 0};

			f.RuleMessageId = mId;
			
			return f;
		}
		private static GenericForum CreateTapuzClubs()
		{
			GenericForum f = new GenericForum();
			f.Name = "Tapuz Clubs";
			f.MainLink = "http://www.tapuz.co.il/communa/";

			ForumRule
				fId0 = new ForumRule();

			fId0.ruleAction = RuleAction.RxMatch;
			fId0.actionParams = new object[] { "/Communa/usercommuna.asp\\?communaid=\\d+" };

			f.RuleForumIdentifier = fId0;

			ForumRule
				fLink0 = new ForumRule(),
				fLink1 = new ForumRule(),
				fLink2 = new ForumRule(),
				fLink3 = new ForumRule();

			fLink0.ruleAction = RuleAction.AddToString;
			fLink0.actionParams = new object[] { "&r=1" };
			fLink0.nextRule = fLink1;
			fLink1.ruleAction = RuleAction.DownloadPage;
			fLink1.actionParams = new object[] { "hebrew" };
			fLink1.nextRule = fLink2;
			fLink2.ruleAction = RuleAction.RemoveChars;
			fLink2.actionParams = new object[] { '\r', '\n', '\t' };
			fLink2.nextRule = fLink3;
			fLink3.ruleAction = RuleAction.GetMessageLinksRx;
			fLink3.actionParams = new object[] 
			{ 
				"(?<link>MArr\\(\\d+.*?\\);.*?Mtbl\\(\\d+.*?\"(?<date>\\d{2}:\\d{2}\",\"\\d{2}/\\d{2}/\\d{2})\".*?\\);)",
				"HH:mm\\\",\\\"dd/MM/yy" };

			f.RuleMessageLinks = fLink0;

			ForumRule
				mDate0 = new ForumRule(), mDate1 = new ForumRule(),
				mText0 = new ForumRule(), mTopic0 = new ForumRule(),
				mId = new ForumRule();

			mDate0.ruleAction = RuleAction.GetRxMatches;
			mDate0.actionParams = new object[] { "\\d{2}:\\d{2}\",\"\\d{2}/\\d{2}/\\d{2}", 0, 0 };
			mDate0.nextRule = mDate1;

			mDate1.ruleAction = RuleAction.GetDate;
			mDate1.actionParams = new object[] { "HH:mm\\\",\\\"dd/MM/yy" };

			f.RuleMessageDate = mDate0;

			mText0.ruleAction = RuleAction.GetRxMatches;
			mText0.actionParams = new object[] { "MArr\\(\\d+,\\d+,\\d+,\"(?<text>.*?)\"", "text", 0 };

			f.RuleMessageText = mText0;

			mTopic0.ruleAction = RuleAction.GetRxMatches;
			mTopic0.actionParams = new object[] { "mtbl\\((.+?,){6}\"(?<topic>.*?)\"", "topic", 0 };

			f.RuleMessageTopic = mTopic0;

			mId.ruleAction = RuleAction.GetRxMatches;
			mId.actionParams = new object[] { "mtbl\\(\\d+,\\d+,\\d+,(?<id>\\d+)", "id", 0 };

			f.RuleMessageId = mId;

			return f;
		}
		private static GenericForum CreateWalla()
		{
			GenericForum f = new GenericForum();
			f.Name = "Walla Forums";
			f.MainLink = "http://forums.walla.co.il/?w=/&all=1";
			ForumRule
				fId0 = new ForumRule();

			fId0.ruleAction = RuleAction.RxMatch;
			fId0.actionParams = new object[] { @"http://forums.walla.co.il/\?w=/(\d+)/(\d+)" };

			f.RuleForumIdentifier = fId0;

			ForumRule 
				links0 = new ForumRule(), 
				links1 = new ForumRule();

			links0.ruleAction = RuleAction.DownloadPage;
			links0.actionParams = new object[] { "hebrew" };
			links0.nextRule = links1;
			links1.ruleAction = RuleAction.GetMessageLinksRx;
			links1.actionParams = new object[] { "<td class=\"w2 d\">(?<date>\\d{2}:\\d{2} \\d{2}/\\d{2}/\\d{2}).*?href=\"(?<link>\\?w=(/\\d+){3})", "HH:mm dd/MM/yy" };

			f.RuleMessageLinks = links0;

			Rule
				MessageTopicRule = new Rule("td", "class", "w3b"),
				MessageTextRule = new Rule("td", "class", "w3");
			ForumRule
				mText0 = new ForumRule(),
				mText1 = new ForumRule(),
				mText2 = new ForumRule(),

				mTopic0 = new ForumRule(),
				mTopic1 = new ForumRule(),
				mTopic2 = new ForumRule(),

				mDate0 = new ForumRule(),
				mDate1 = new ForumRule(),

				mId0 = new ForumRule(),

				mDownload0 = new ForumRule(),
				mDownload1 = new ForumRule();

			mDownload0.ruleAction = RuleAction.AddStringTo;
			mDownload0.actionParams = new object[] { "http://forums.walla.co.il/"};
			mDownload0.nextRule = mDownload1;
			mDownload1.ruleAction = RuleAction.DownloadPage;
			mDownload1.actionParams = new object[] { "hebrew" };

			f.RuleDownloadMessage = mDownload0;
			
			mText0.ruleAction = RuleAction.GetNodes;
			mText0.nextRule = mText1;
			mText1.ruleAction = RuleAction.GetNodeByRule;
			mText1.actionParams = new object[] { MessageTextRule };
			mText1.nextRule = mText2;
			mText2.ruleAction = RuleAction.GetTextFromNode;

			f.RuleMessageText = mText0;

			mTopic0.ruleAction = RuleAction.GetNodes;
			mTopic0.nextRule = mTopic1;
			mTopic1.ruleAction = RuleAction.GetNodeByRule;
			mTopic1.actionParams = new object[] { MessageTopicRule };
			mTopic1.nextRule = mTopic2;
			mTopic2.ruleAction = RuleAction.GetTextFromNode;

			f.RuleMessageTopic = mTopic0;

			mDate0.ruleAction = RuleAction.GetRxMatches;
			mDate0.actionParams = new object[] { @"(\d+)/(\d+)/\d\d\d\d שעה: \d\d:\d\d", 0, 0 };
			mDate0.nextRule = mDate1;
			mDate1.ruleAction = RuleAction.GetDate;
			mDate1.actionParams = new object[] { "d/M/yyyy שעה: HH:mm" };

			f.RuleMessageDate = mDate0;

			mId0.ruleAction = RuleAction.GetRxMatches;
			mId0.actionParams = new object[] { @"location.href='\?w=/(\d+)/(\d+)/(\d+)//response" , 3, 0};

			f.RuleMessageId = mId0;

			return f;
		}
		private static GenericForum CreateNana()
		{
			GenericForum f = new GenericForum();
			f.Name = "Nana Forums";
			f.MainLink = "http://forums.nana10.co.il/Category/?CategoryID=245&TypeID=1";

			ForumRule
				fid0 = new ForumRule();

			fid0.ruleAction = RuleAction.RxMatch;
			fid0.actionParams = new object[] { @"http://forums.nana10.co.il/forum/\?forumid=(\d+)\Z" };
			
			f.RuleForumIdentifier = fid0;

			ForumRule
				fLink0 = new ForumRule(),
				fLink1 = new ForumRule(),
				fLink2 = new ForumRule(),
				fLink3 = new ForumRule(),
				fLink4 = new ForumRule(),
				fLink5 = new ForumRule();

			fLink0.ruleAction = RuleAction.Split;
			fLink0.actionParams = new object[] { '?' };
			fLink0.nextRule = fLink1;
			fLink1.ruleAction = RuleAction.FromListString;
			fLink1.actionParams = new object[] { 1 };
			fLink1.nextRule = fLink2;
			fLink2.ruleAction = RuleAction.AddStringTo;
			fLink2.actionParams = new object[] { "http://forums.nana10.co.il/Forum/MessagesList.asp?" };
			fLink2.nextRule = fLink3;
			fLink3.ruleAction = RuleAction.DownloadPage;
			fLink3.actionParams = new object[] { "utf-8" };
			fLink3.nextRule = fLink4;
			fLink4.ruleAction = RuleAction.RemoveChars;
			fLink4.actionParams = new object[] { '\r', '\n', '\t' };
			fLink4.nextRule = fLink5;
			fLink5.ruleAction = RuleAction.GetMessageLinksRx;
			fLink5.actionParams = new object[] 
			{ @"if\((?<link>.*?(?<date>\d{2}:\d{2} \d{2}/\d{2}/\d{2}).*?)</script>"
				,"HH:mm dd/MM/yy" };

			f.RuleMessageLinks = fLink0;

			ForumRule
				mText0 = new ForumRule();

			mText0.ruleAction = RuleAction.GetRxMatches;
			mText0.actionParams = new object[] { @"'(<P.*</P>)',", 1, 0};

			f.RuleMessageText = mText0;

			ForumRule
				mTopic0 = new ForumRule();

			mTopic0.ruleAction = RuleAction.GetRxMatches;
			mTopic0.actionParams = new object[] { @"false,'(.*?)','<P", 1, 0 };

			f.RuleMessageTopic = mTopic0;

			ForumRule
				mDate0 = new ForumRule(),
				mDate1 = new ForumRule();

			mDate0.ruleAction = RuleAction.GetRxMatches;
			mDate0.actionParams = new object[] { @"'(\d\d:\d\d \d\d/\d\d/\d\d)',", 1, 0 };
			mDate0.nextRule = mDate1;
			mDate1.ruleAction = RuleAction.GetDate;
			mDate1.actionParams = new object[] { "HH:mm dd/MM/yy" };

			f.RuleMessageDate = mDate0;

			ForumRule
				mId0 = new ForumRule();

			mId0.ruleAction = RuleAction.GetRxMatches;
			mId0.actionParams = new object[] { "[\"ID\"]=(?<id>\\d+);|pAN\\(oCurrNode,(?<id>\\d+)\\);", "id", 0 };

			f.RuleMessageId = mId0;

			return f;
		}
		private static GenericForum CreateFresh()
		{
			GenericForum f = new GenericForum();
			f.Name = "Fresh Forums";
			f.MainLink = "http://www.fresh.co.il/vBulletin/";
			ForumRule
				fid0 = new ForumRule();
			fid0.ruleAction = RuleAction.RxMatch;
			fid0.actionParams = new object[] { @"http://www.fresh.co.il/vBulletin/forumdisplay.php\?f=(1[2-9]|[2-9]\d+|\d{3,})" };

			f.RuleForumIdentifier = fid0;

			ForumRule
				fLink0 = new ForumRule(),
				fLink1 = new ForumRule(),
				fLink2=new ForumRule();

			fLink0.ruleAction = RuleAction.DownloadPage;
			fLink0.actionParams = new object[] {"hebrew" };
			fLink0.nextRule = fLink1;
			fLink1.ruleAction = RuleAction.RemoveChars;
			fLink1.actionParams = new object[] { '\r','\n','\t' };
			fLink1.nextRule = fLink2;
			fLink2.ruleAction = RuleAction.GetMessageLinksRx;
			fLink2.actionParams = new object[] 
			{ "text-align:left;.*?(?<date>\\d{2}-\\d{2}-\\d{4}(?:.*?)\\d{2}:\\d{2}).*?(?<link>showthread.php\\?goto=lastpost&amp;t=\\d+)",
			"dd-MM-yyyy <\\span cla\\s\\s=\\\"\\ti\\me\\\">HH:mm"};

			f.RuleMessageLinks = fLink0;

			ForumRule
				fDownload0 = new ForumRule(),
				fDownload1 = new ForumRule(),
				fDownload2 = new ForumRule();

			fDownload0.ruleAction = RuleAction.AddStringTo;
			fDownload0.actionParams = new object[] { "http://www.fresh.co.il/vBulletin/" };
			fDownload0.nextRule = fDownload1;
			fDownload1.ruleAction = RuleAction.RemoveFromString;
			fDownload1.actionParams = new object[] { "amp;"};
			fDownload1.nextRule = fDownload2;
			fDownload2.ruleAction = RuleAction.DownloadPage;
			fDownload2.actionParams = new object[] { "hebrew"};

			f.RuleDownloadMessage = fDownload0;

			ForumRule
				mText0 = new ForumRule(),
				mText1 = new ForumRule(),
				mText2 = new ForumRule();


			mText0.ruleAction = RuleAction.GetNodes;
			mText0.nextRule = mText1;
			mText1.ruleAction = RuleAction.GetNodeByRule;
			mText1.actionParams = new object[] { new Rule("blockquote", "", "") };
			mText1.nextRule = mText2;
			mText2.ruleAction = RuleAction.GetTextFromNode;
			mText2.actionParams = new object[] { true };

			f.RuleMessageText = mText0;

			ForumRule
				mTopic0 = new ForumRule(),
				mTopic1 = new ForumRule(),
				mTopic2 = new ForumRule();

			mTopic0.ruleAction = RuleAction.GetNodes;
			mTopic0.nextRule = mTopic1;
			mTopic1.ruleAction = RuleAction.GetNodeByRule;
			mTopic1.actionParams = new object[] { new Rule("span", "style", "font-family: arial; font-weight: bold; font-size: 16px; color: Black;") };
			mTopic1.nextRule = mTopic2;
			mTopic2.ruleAction = RuleAction.GetTextFromNode;
			mTopic2.actionParams = new object[] { true };


			f.RuleMessageTopic = mTopic0;

			ForumRule
				mDate0 = new ForumRule(),
				mDate1 = new ForumRule(),
				mDate2 = new ForumRule();

			mDate0.ruleAction = RuleAction.RemoveChars;
			mDate0.actionParams = new object[] { '\r', '\n', '\t' };
			mDate0.nextRule = mDate1;
			mDate1.ruleAction = RuleAction.GetRxMatches;
			mDate1.actionParams = new object[] { @"\d\d-\d\d-\d\d\d\d, \d\d:\d\d" ,0, 0 };
			mDate1.nextRule = mDate2;
			mDate2.ruleAction = RuleAction.GetDate;
			mDate2.actionParams = new object[] { "dd-MM-yyyy, HH:mm" };

			f.RuleMessageDate = mDate0;

			ForumRule
				mId0 = new ForumRule();


			mId0.ruleAction = RuleAction.GetRxMatches;
			mId0.actionParams = new object[] { @"showthread.php\?t=(\d+)&amp;goto=nextnewest", 1, 0 };

			f.RuleMessageId = mId0;

			return f;
		}
		private static GenericForum CreateHyde()
		{
			var f = new GenericForum();
			f.Name = "Hydepark Forums";
			f.MainLink = "http://www.hydepark.hevre.co.il/listforums.asp";

			ForumRule
				id0 = new ForumRule();
			id0.ruleAction = RuleAction.RxMatch;
			id0.actionParams = new object[] { @"http://www.hydepark.hevre.co.il/forum.asp\?cat_id=\d+&forum_id=\d+" };
			f.RuleForumIdentifier = id0;

			ForumRule
				link0 = new ForumRule(), link1=new ForumRule(), link2=new ForumRule();

			link0.ruleAction = RuleAction.DownloadPage;
			link0.actionParams = new object[] { "hebrew"};
			link0.nextRule = link1;
			link1.ruleAction = RuleAction.RemoveChars;
			link1.actionParams = new object[] { '\r','\n','\t' };
			link1.nextRule = link2;
			link2.ruleAction = RuleAction.GetMessageLinksRx;
			link2.actionParams = new object[] 
			{ "white-space.*?(?<date>\\d{2}:\\d{2}  \\d{2}/\\d{2}/\\d{4}).*?"+
				"(?<link>topic.asp\\?cat_id=\\d+&topic_id=\\d+&amp;whichpage=\\d+#R_\\d+)"
				,"HH:mm  dd/MM/yyyy"};

			f.RuleMessageLinks = link0;

			ForumRule
				download0 = new ForumRule(),
				download1 = new ForumRule(),
				download2 = new ForumRule(),
				download3 = new ForumRule(),
				download4 = new ForumRule(),
				download5 = new ForumRule(),
				download6 = new ForumRule(),
				download7 = new ForumRule(),
				download8 = new ForumRule(),
				download9 = new ForumRule(),
				download10 = new ForumRule(),
				download61 = new ForumRule(),
				download62 = new ForumRule();

			download0.ruleAction = RuleAction.AddStringTo;
			download0.actionParams = new object[] { "http://www.hydepark.hevre.co.il/" };
			download0.nextRule = download1;
			download1.ruleAction = RuleAction.RemoveFromString;
			download1.actionParams = new object[] { "amp;"};
			download1.nextRule = download2;
			download2.ruleAction = RuleAction.DownloadPage;
			download2.actionParams = new object[] { "hebrew"};
			download2.nextRule = download3;

			download3.ruleAction = RuleAction.If;
			download3.actionParams = new object[] { download4, download5, download9};

			download4.ruleAction = RuleAction.RxMatch;
			download4.actionParams = new object[] { "title>Object moved</title"};

			download5.ruleAction = RuleAction.GetRxMatches;
			download5.actionParams = new object[] { "href=\"(?<link>.*?)\"", "link", 0};
			download5.nextRule = download6;

			download6.ruleAction = RuleAction.RemoveFromString;
			download6.actionParams = new object[] { "amp;" };
			download6.nextRule = download61;

			download61.ruleAction = RuleAction.If;
			download61.actionParams = new object[] { download62, download8, download7};

			download62.ruleAction = RuleAction.RxMatch;
			download62.actionParams = new object[] { "bhol\\.co\\.il" };

			download7.ruleAction = RuleAction.AddStringTo;
			download7.actionParams = new object[] { "http://www.hydepark.hevre.co.il/" };
			download7.nextRule = download8;

			download8.ruleAction = RuleAction.DownloadPage;
			download8.actionParams = new object[] { "hebrew" };
			download8.nextRule = download3;

			download9.ruleAction = RuleAction.RemoveChars;
			download9.actionParams = new object[] { '\r', '\n', '\t'};
			download9.nextRule = download10;
			download10.ruleAction = RuleAction.GetRxMatches;
			download10.actionParams = new object[] { "function init\\d+\\(\\)(?<msg>.*?begin tochen topic.*?)<!--end tochen", "msg", "last" };

			f.RuleDownloadMessage = download0;

			ForumRule
				text0 = new ForumRule();

			text0.ruleAction = RuleAction.GetRxMatches;
			text0.actionParams = new object[] { "<font size='2'>(?<text>.*)</font>", "text", "first" };

			f.RuleMessageText = text0;


			ForumRule
				topic0 = new ForumRule();

			topic0.ruleAction = RuleAction.GetRxMatches;
			topic0.actionParams = new object[] { "<font size='3'>(?<text>.*?)</font>", "text", "first" };

			f.RuleMessageTopic = topic0;

			ForumRule
				date0 = new ForumRule(), date1=new ForumRule();

			date0.ruleAction = RuleAction.GetRxMatches;
			date0.actionParams = new object[] { "(?<date>נשלח ב-\\d+/\\d+/\\d+&nbsp;\\d+:\\d+)", "date", "last" };
			date0.nextRule = date1;
			date1.ruleAction = RuleAction.GetDate;
			date1.actionParams = new object[] { "נשלח ב-d/M/yyyy&nb\\sp;HH:mm" };

			f.RuleMessageDate = date0;

			ForumRule
				uid0 = new ForumRule();

			uid0.ruleAction = RuleAction.GetRxMatches;
			uid0.actionParams = new object[] { "productMenu(?<id>\\d+).showSubIcon", "id", "first" };
			f.RuleMessageId = uid0;


			return f;
		}
		private static GenericForum CreateMako()
		{
			var f = new GenericForum();

			f.MainLink = "http://www.mako.co.il/forum";
			ForumRule
				id0 = new ForumRule();
			id0.ruleAction = RuleAction.RxMatch;
			id0.actionParams = new object[] { "/forum/Forum-\\w+.htm\\z"};

			f.RuleForumIdentifier = id0;

			ForumRule
				link0 = new ForumRule(),
				link1 = new ForumRule();

			link0.ruleAction = RuleAction.DownloadPage;
			link0.actionParams = new object[] { "utf-8"};
			link0.nextRule = link1;
			link1.ruleAction = RuleAction.GetMessageLinksRx;
			link1.actionParams = new object[] 
			{ 
				"forum_right.*?margin-right: 2px;", 
				"HH:mm | dd/MM/yy"
			};

			return f;
		}
	}

}
